.class public Lcom/zuimeia/sdk/download/providers/downloads/Helpers;
.super Ljava/lang/Object;
.source "Helpers.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;,
        Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
    }
.end annotation


# static fields
.field private static final CONTENT_DISPOSITION_PATTERN:Ljava/util/regex/Pattern;

.field public static sRandom:Ljava/util/Random;


# direct methods
.method static constructor <clinit>()V
    .registers 4

    .prologue
    .line 45
    new-instance v0, Ljava/util/Random;

    invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

    move-result-wide v2

    invoke-direct {v0, v2, v3}, Ljava/util/Random;-><init>(J)V

    sput-object v0, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->sRandom:Ljava/util/Random;

    .line 50
    const-string v0, "attachment;\\s*filename\\s*=\\s*\"([^\"]*)\""

    .line 51
    invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v0

    sput-object v0, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->CONTENT_DISPOSITION_PATTERN:Ljava/util/regex/Pattern;

    .line 50
    return-void
.end method

.method private constructor <init>()V
    .registers 1

    .prologue
    .line 53
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 54
    return-void
.end method

.method private static checkCanHandleDownload(Landroid/content/Context;Ljava/lang/String;IZ)V
    .registers 11
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "mimeType"    # Ljava/lang/String;
    .param p2, "destination"    # I
    .param p3, "isPublicApi"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    const/16 v6, 0x196

    .line 208
    if-eqz p3, :cond_5

    .line 245
    :cond_4
    return-void

    .line 212
    :cond_5
    if-nez p2, :cond_4

    .line 213
    if-nez p1, :cond_11

    .line 214
    new-instance v3, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const-string v4, "external download with no mime type not allowed"

    invoke-direct {v3, v6, v4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v3

    .line 221
    :cond_11
    new-instance v0, Landroid/content/Intent;

    const-string v3, "android.intent.action.VIEW"

    invoke-direct {v0, v3}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 230
    .local v0, "intent":Landroid/content/Intent;
    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v1

    .line 231
    .local v1, "pm":Landroid/content/pm/PackageManager;
    const-string v3, "file"

    const-string v4, ""

    const/4 v5, 0x0

    invoke-static {v3, v4, v5}, Landroid/net/Uri;->fromParts(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v3

    invoke-virtual {v0, v3, p1}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 232
    const/high16 v3, 0x10000

    invoke-virtual {v1, v0, v3}, Landroid/content/pm/PackageManager;->resolveActivity(Landroid/content/Intent;I)Landroid/content/pm/ResolveInfo;

    move-result-object v2

    .line 235
    .local v2, "ri":Landroid/content/pm/ResolveInfo;
    if-nez v2, :cond_4

    .line 240
    new-instance v3, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const-string v4, "no handler found for this download type"

    invoke-direct {v3, v6, v4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v3
.end method

.method private static chooseExtensionFromFilename(Ljava/lang/String;ILjava/lang/String;I)Ljava/lang/String;
    .registers 9
    .param p0, "mimeType"    # Ljava/lang/String;
    .param p1, "destination"    # I
    .param p2, "filename"    # Ljava/lang/String;
    .param p3, "dotIndex"    # I

    .prologue
    .line 441
    const/4 v0, 0x0

    .line 442
    .local v0, "extension":Ljava/lang/String;
    if-eqz p0, :cond_33

    .line 445
    const/16 v3, 0x2e

    invoke-virtual {p2, v3}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v1

    .line 446
    .local v1, "lastDotIndex":I
    invoke-static {}, Landroid/webkit/MimeTypeMap;->getSingleton()Landroid/webkit/MimeTypeMap;

    move-result-object v3

    add-int/lit8 v4, v1, 0x1

    .line 448
    invoke-virtual {p2, v4}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v4

    .line 447
    invoke-virtual {v3, v4}, Landroid/webkit/MimeTypeMap;->getMimeTypeFromExtension(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    .line 449
    .local v2, "typeFromExt":Ljava/lang/String;
    if-eqz v2, :cond_1f

    invoke-virtual {v2, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v3

    if-nez v3, :cond_33

    .line 450
    :cond_1f
    const-string v3, "application/octet-stream"

    invoke-virtual {v3, p0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_3a

    const-string v3, "application/vnd.android.package-archive"

    invoke-virtual {v3, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_3a

    .line 451
    const-string v0, ".apk"

    .line 456
    :goto_31
    if-eqz v0, :cond_33

    .line 468
    .end local v1    # "lastDotIndex":I
    .end local v2    # "typeFromExt":Ljava/lang/String;
    :cond_33
    if-nez v0, :cond_39

    .line 472
    invoke-virtual {p2, p3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    .line 474
    :cond_39
    return-object v0

    .line 453
    .restart local v1    # "lastDotIndex":I
    .restart local v2    # "typeFromExt":Ljava/lang/String;
    :cond_3a
    const/4 v3, 0x0

    invoke-static {p0, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->chooseExtensionFromMimeType(Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object v0

    goto :goto_31
.end method

.method private static chooseExtensionFromMimeType(Ljava/lang/String;Z)Ljava/lang/String;
    .registers 5
    .param p0, "mimeType"    # Ljava/lang/String;
    .param p1, "useDefaults"    # Z

    .prologue
    .line 400
    const/4 v0, 0x0

    .line 401
    .local v0, "extension":Ljava/lang/String;
    if-eqz p0, :cond_20

    .line 402
    invoke-static {}, Landroid/webkit/MimeTypeMap;->getSingleton()Landroid/webkit/MimeTypeMap;

    move-result-object v1

    invoke-virtual {v1, p0}, Landroid/webkit/MimeTypeMap;->getExtensionFromMimeType(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 404
    if-eqz v0, :cond_20

    .line 408
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "."

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 416
    :cond_20
    if-nez v0, :cond_3a

    .line 417
    if-eqz p0, :cond_40

    invoke-virtual {p0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v1

    const-string v2, "text/"

    invoke-virtual {v1, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_40

    .line 418
    const-string v1, "text/html"

    invoke-virtual {p0, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_3b

    .line 422
    const-string v0, ".html"

    .line 436
    :cond_3a
    :goto_3a
    return-object v0

    .line 423
    :cond_3b
    if-eqz p1, :cond_3a

    .line 427
    const-string v0, ".txt"

    goto :goto_3a

    .line 429
    :cond_40
    if-eqz p1, :cond_3a

    .line 433
    const-string v0, ".bin"

    goto :goto_3a
.end method

.method private static chooseFilename(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;
    .registers 12
    .param p0, "url"    # Ljava/lang/String;
    .param p1, "hint"    # Ljava/lang/String;
    .param p2, "contentDisposition"    # Ljava/lang/String;
    .param p3, "contentLocation"    # Ljava/lang/String;
    .param p4, "destination"    # I

    .prologue
    const/16 v6, 0x3f

    const/16 v5, 0x2f

    .line 320
    const/4 v2, 0x0

    .line 323
    .local v2, "filename":Ljava/lang/String;
    if-nez v2, :cond_1d

    if-eqz p1, :cond_1d

    const-string v4, "/"

    invoke-virtual {p1, v4}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v4

    if-nez v4, :cond_1d

    .line 327
    invoke-virtual {p1, v5}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v4

    add-int/lit8 v3, v4, 0x1

    .line 328
    .local v3, "index":I
    if-lez v3, :cond_86

    .line 329
    invoke-virtual {p1, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v2

    .line 337
    .end local v3    # "index":I
    :cond_1d
    :goto_1d
    if-nez v2, :cond_33

    if-eqz p2, :cond_33

    .line 338
    invoke-static {p2}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->parseContentDisposition(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    .line 339
    if-eqz v2, :cond_33

    .line 344
    invoke-virtual {v2, v5}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v4

    add-int/lit8 v3, v4, 0x1

    .line 345
    .restart local v3    # "index":I
    if-lez v3, :cond_33

    .line 346
    invoke-virtual {v2, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v2

    .line 352
    .end local v3    # "index":I
    :cond_33
    if-nez v2, :cond_57

    if-eqz p3, :cond_57

    .line 353
    invoke-static {p3}, Landroid/net/Uri;->decode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 354
    .local v0, "decodedContentLocation":Ljava/lang/String;
    if-eqz v0, :cond_57

    const-string v4, "/"

    .line 355
    invoke-virtual {v0, v4}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v4

    if-nez v4, :cond_57

    .line 356
    invoke-virtual {v0, v6}, Ljava/lang/String;->indexOf(I)I

    move-result v4

    if-gez v4, :cond_57

    .line 361
    invoke-virtual {v0, v5}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v4

    add-int/lit8 v3, v4, 0x1

    .line 362
    .restart local v3    # "index":I
    if-lez v3, :cond_88

    .line 363
    invoke-virtual {v0, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v2

    .line 371
    .end local v0    # "decodedContentLocation":Ljava/lang/String;
    .end local v3    # "index":I
    :cond_57
    :goto_57
    if-nez v2, :cond_79

    .line 372
    invoke-static {p0}, Landroid/net/Uri;->decode(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 373
    .local v1, "decodedUrl":Ljava/lang/String;
    if-eqz v1, :cond_79

    const-string v4, "/"

    invoke-virtual {v1, v4}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v4

    if-nez v4, :cond_79

    .line 374
    invoke-virtual {v1, v6}, Ljava/lang/String;->indexOf(I)I

    move-result v4

    if-gez v4, :cond_79

    .line 375
    invoke-virtual {v1, v5}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v4

    add-int/lit8 v3, v4, 0x1

    .line 376
    .restart local v3    # "index":I
    if-lez v3, :cond_79

    .line 380
    invoke-virtual {v1, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v2

    .line 386
    .end local v1    # "decodedUrl":Ljava/lang/String;
    .end local v3    # "index":I
    :cond_79
    if-nez v2, :cond_7d

    .line 390
    const-string v2, "downloadfile"

    .line 393
    :cond_7d
    const-string v4, "[^a-zA-Z0-9\\.\\-_]+"

    const-string v5, "_"

    invoke-virtual {v2, v4, v5}, Ljava/lang/String;->replaceAll(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    .line 395
    return-object v2

    .line 331
    .restart local v3    # "index":I
    :cond_86
    move-object v2, p1

    goto :goto_1d

    .line 365
    .restart local v0    # "decodedContentLocation":Ljava/lang/String;
    :cond_88
    move-object v2, v0

    goto :goto_57
.end method

.method private static chooseFullPath(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;
    .registers 22
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "hint"    # Ljava/lang/String;
    .param p3, "contentDisposition"    # Ljava/lang/String;
    .param p4, "contentLocation"    # Ljava/lang/String;
    .param p5, "mimeType"    # Ljava/lang/String;
    .param p6, "destination"    # I
    .param p7, "contentLength"    # J
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 199
    move-object/from16 v0, p5

    move/from16 v1, p6

    move-wide/from16 v2, p7

    invoke-static {p0, v0, v1, v2, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->locateDestinationDirectory(Landroid/content/Context;Ljava/lang/String;IJ)Ljava/io/File;

    move-result-object v12

    .line 201
    .local v12, "base":Ljava/io/File;
    invoke-virtual {v12}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v4

    move-object v5, p1

    move-object/from16 v6, p3

    move-object/from16 v7, p4

    move-object/from16 v8, p5

    move/from16 v9, p6

    move-wide/from16 v10, p7

    invoke-static/range {v4 .. v11}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->generateFilePath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;

    move-result-object v4

    return-object v4
.end method

.method private static chooseUniqueFilename(ILjava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;
    .registers 12
    .param p0, "destination"    # I
    .param p1, "filename"    # Ljava/lang/String;
    .param p2, "extension"    # Ljava/lang/String;
    .param p3, "recoveryDir"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 480
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 481
    .local v0, "fullFilename":Ljava/lang/String;
    new-instance v5, Ljava/io/File;

    invoke-direct {v5, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v5}, Ljava/io/File;->exists()Z

    move-result v5

    if-nez v5, :cond_20

    if-nez p3, :cond_20

    move-object v1, v0

    .line 501
    .end local v0    # "fullFilename":Ljava/lang/String;
    .local v1, "fullFilename":Ljava/lang/String;
    :goto_1f
    return-object v1

    .line 484
    .end local v1    # "fullFilename":Ljava/lang/String;
    .restart local v0    # "fullFilename":Ljava/lang/String;
    :cond_20
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "-"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    .line 496
    const/4 v4, 0x1

    .line 497
    .local v4, "sequence":I
    const/4 v3, 0x1

    .local v3, "magnitude":I
    :goto_35
    const v5, 0x3b9aca00

    if-ge v3, v5, :cond_70

    .line 498
    const/4 v2, 0x0

    .local v2, "iteration":I
    :goto_3b
    const/16 v5, 0x9

    if-ge v2, v5, :cond_6d

    .line 499
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 500
    new-instance v5, Ljava/io/File;

    invoke-direct {v5, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v5}, Ljava/io/File;->exists()Z

    move-result v5

    if-nez v5, :cond_61

    move-object v1, v0

    .line 501
    .end local v0    # "fullFilename":Ljava/lang/String;
    .restart local v1    # "fullFilename":Ljava/lang/String;
    goto :goto_1f

    .line 507
    .end local v1    # "fullFilename":Ljava/lang/String;
    .restart local v0    # "fullFilename":Ljava/lang/String;
    :cond_61
    sget-object v5, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->sRandom:Ljava/util/Random;

    invoke-virtual {v5, v3}, Ljava/util/Random;->nextInt(I)I

    move-result v5

    add-int/lit8 v5, v5, 0x1

    add-int/2addr v4, v5

    .line 498
    add-int/lit8 v2, v2, 0x1

    goto :goto_3b

    .line 497
    :cond_6d
    mul-int/lit8 v3, v3, 0xa

    goto :goto_35

    .line 510
    .end local v2    # "iteration":I
    :cond_70
    new-instance v5, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v6, 0x1ec

    const-string v7, "failed to generate an unused filename on internal download storage"

    invoke-direct {v5, v6, v7}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v5
.end method

.method static deleteFile(Landroid/content/Context;Landroid/content/ContentResolver;JLjava/lang/String;Ljava/lang/String;)V
    .registers 14
    .param p0, "mContext"    # Landroid/content/Context;
    .param p1, "resolver"    # Landroid/content/ContentResolver;
    .param p2, "id"    # J
    .param p4, "path"    # Ljava/lang/String;
    .param p5, "mimeType"    # Ljava/lang/String;

    .prologue
    .line 815
    :try_start_0
    new-instance v1, Ljava/io/File;

    invoke-direct {v1, p4}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 816
    .local v1, "file":Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->delete()Z
    :try_end_8
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_8} :catch_1c

    .line 820
    .end local v1    # "file":Ljava/io/File;
    :goto_8
    invoke-static {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Downloads;->getAllDownloadsContentURI(Landroid/content/Context;)Landroid/net/Uri;

    move-result-object v2

    const-string v3, "_id = ? "

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/String;

    const/4 v5, 0x0

    .line 821
    invoke-static {p2, p3}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    .line 820
    invoke-virtual {p1, v2, v3, v4}, Landroid/content/ContentResolver;->delete(Landroid/net/Uri;Ljava/lang/String;[Ljava/lang/String;)I

    .line 822
    return-void

    .line 817
    :catch_1c
    move-exception v0

    .line 818
    .local v0, "e":Ljava/lang/Exception;
    const-string v2, "DownloadManager"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "file: \'"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v4, "\' couldn\'t be deleted"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_8
.end method

.method private static generateFilePath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;
    .registers 14
    .param p0, "basePath"    # Ljava/lang/String;
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "contentDisposition"    # Ljava/lang/String;
    .param p3, "contentLocation"    # Ljava/lang/String;
    .param p4, "mimeType"    # Ljava/lang/String;
    .param p5, "destination"    # I
    .param p6, "contentLength"    # J
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 167
    const/4 v4, 0x0

    invoke-static {p1, v4, p2, p3, p5}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->chooseFilename(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;

    move-result-object v2

    .line 172
    .local v2, "filename":Ljava/lang/String;
    const/4 v1, 0x0

    .line 173
    .local v1, "extension":Ljava/lang/String;
    const/16 v4, 0x2e

    invoke-virtual {v2, v4}, Ljava/lang/String;->indexOf(I)I

    move-result v0

    .line 174
    .local v0, "dotIndex":I
    if-gez v0, :cond_46

    .line 175
    const/4 v4, 0x1

    invoke-static {p4, v4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->chooseExtensionFromMimeType(Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object v1

    .line 182
    :goto_13
    const-string v4, "recovery"

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    .line 183
    invoke-virtual {v4, v5}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v3

    .line 185
    .local v3, "recoveryDir":Z
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v4, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    sget-object v5, Ljava/io/File;->separator:Ljava/lang/String;

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 191
    invoke-static {p5, v2, v1, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->chooseUniqueFilename(ILjava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;

    move-result-object v4

    return-object v4

    .line 177
    .end local v3    # "recoveryDir":Z
    :cond_46
    invoke-static {p4, p5, v2, v0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->chooseExtensionFromFilename(Ljava/lang/String;ILjava/lang/String;I)Ljava/lang/String;

    move-result-object v1

    .line 179
    const/4 v4, 0x0

    invoke-virtual {v2, v4, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v2

    goto :goto_13
.end method

.method public static generateSaveFile(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJZ)Ljava/lang/String;
    .registers 11
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "url"    # Ljava/lang/String;
    .param p2, "hint"    # Ljava/lang/String;
    .param p3, "contentDisposition"    # Ljava/lang/String;
    .param p4, "contentLocation"    # Ljava/lang/String;
    .param p5, "mimeType"    # Ljava/lang/String;
    .param p6, "destination"    # I
    .param p7, "contentLength"    # J
    .param p9, "isPublicApi"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 99
    invoke-static {p0, p5, p6, p9}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->checkCanHandleDownload(Landroid/content/Context;Ljava/lang/String;IZ)V

    .line 100
    const/4 v0, 0x4

    if-ne p6, v0, :cond_b

    .line 101
    invoke-static/range {p1 .. p8}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->getPathForFileUri(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;

    move-result-object v0

    .line 104
    :goto_a
    return-object v0

    :cond_b
    invoke-static/range {p0 .. p8}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->chooseFullPath(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;

    move-result-object v0

    goto :goto_a
.end method

.method public static getAvailableBytes(Ljava/io/File;)J
    .registers 9
    .param p0, "root"    # Ljava/io/File;

    .prologue
    .line 298
    new-instance v2, Landroid/os/StatFs;

    invoke-virtual {p0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    .line 301
    .local v2, "stat":Landroid/os/StatFs;
    invoke-virtual {v2}, Landroid/os/StatFs;->getAvailableBlocks()I

    move-result v3

    int-to-long v4, v3

    const-wide/16 v6, 0x4

    sub-long v0, v4, v6

    .line 302
    .local v0, "availableBlocks":J
    invoke-virtual {v2}, Landroid/os/StatFs;->getBlockSize()I

    move-result v3

    int-to-long v4, v3

    mul-long/2addr v4, v0

    return-wide v4
.end method

.method private static getExternalDestination(J)Ljava/io/File;
    .registers 8
    .param p0, "contentLength"    # J
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 255
    invoke-static {}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->isExternalMediaMounted()Z

    move-result v2

    if-nez v2, :cond_10

    .line 256
    new-instance v2, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v3, 0x1f3

    const-string v4, "external media not mounted"

    invoke-direct {v2, v3, v4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v2

    .line 261
    :cond_10
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    .line 262
    .local v1, "root":Ljava/io/File;
    invoke-static {v1}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->getAvailableBytes(Ljava/io/File;)J

    move-result-wide v2

    cmp-long v2, v2, p0

    if-gez v2, :cond_2d

    .line 264
    const-string v2, "DownloadManager"

    const-string v3, "download aborted - not enough free space"

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 265
    new-instance v2, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v3, 0x1f2

    const-string v4, "insufficient space on external media"

    invoke-direct {v2, v3, v4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v2

    .line 270
    :cond_2d
    new-instance v0, Ljava/io/File;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v1}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    sget-object v3, Lcom/zuimeia/sdk/download/providers/downloads/Constants;->DEFAULT_DL_SUBDIR:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 271
    .local v0, "base":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->isDirectory()Z

    move-result v2

    if-nez v2, :cond_74

    invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z

    move-result v2

    if-nez v2, :cond_74

    .line 276
    new-instance v2, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v3, 0x1ec

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "getExternalDestination mathod unable to create external downloads directory "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    .line 278
    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-direct {v2, v3, v4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v2

    .line 280
    :cond_74
    return-object v0
.end method

.method public static getFilesystemRoot(Ljava/lang/String;)Ljava/io/File;
    .registers 6
    .param p0, "path"    # Ljava/lang/String;

    .prologue
    .line 152
    invoke-static {}, Landroid/os/Environment;->getDownloadCacheDirectory()Ljava/io/File;

    move-result-object v0

    .line 153
    .local v0, "cache":Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p0, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_f

    .line 158
    .end local v0    # "cache":Ljava/io/File;
    :goto_e
    return-object v0

    .line 156
    .restart local v0    # "cache":Ljava/io/File;
    :cond_f
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    .line 157
    .local v1, "external":Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p0, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_1f

    move-object v0, v1

    .line 158
    goto :goto_e

    .line 160
    :cond_1f
    new-instance v2, Ljava/lang/IllegalArgumentException;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "Cannot determine filesystem root for "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2
.end method

.method private static getPathForFileUri(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;
    .registers 18
    .param p0, "url"    # Ljava/lang/String;
    .param p1, "hint"    # Ljava/lang/String;
    .param p2, "contentDisposition"    # Ljava/lang/String;
    .param p3, "contentLocation"    # Ljava/lang/String;
    .param p4, "mimeType"    # Ljava/lang/String;
    .param p5, "destination"    # I
    .param p6, "contentLength"    # J
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 112
    invoke-static {}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->isExternalMediaMounted()Z

    move-result v1

    if-nez v1, :cond_10

    .line 113
    new-instance v1, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v2, 0x1f3

    const-string v3, "external media not mounted"

    invoke-direct {v1, v2, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v1

    .line 117
    :cond_10
    invoke-static {p1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v1}, Landroid/net/Uri;->getPath()Ljava/lang/String;

    move-result-object v9

    .line 118
    .local v9, "path":Ljava/lang/String;
    const-string v1, "/"

    invoke-virtual {v9, v1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_99

    .line 119
    const/4 v1, 0x0

    invoke-virtual {v9}, Ljava/lang/String;->length()I

    move-result v2

    add-int/lit8 v2, v2, -0x1

    invoke-virtual {v9, v1, v2}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v0

    .line 120
    .local v0, "basePath":Ljava/lang/String;
    new-instance v8, Ljava/io/File;

    invoke-direct {v8, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 121
    .local v8, "baseDir":Ljava/io/File;
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "getPathForFileUri >> "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v8}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-static {v1, v2}, Lcom/zuimeia/sdk/download/utils/LogTimber;->i(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 122
    invoke-virtual {v8}, Ljava/io/File;->isDirectory()Z

    move-result v1

    if-nez v1, :cond_78

    invoke-virtual {v8}, Ljava/io/File;->mkdirs()Z

    move-result v1

    if-nez v1, :cond_78

    .line 127
    new-instance v1, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v2, 0x1ec

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "getPathForFileUri mathod unable to create external downloads directory "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    .line 129
    invoke-virtual {v8}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v1, v2, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v1

    :cond_78
    move-object v1, p0

    move-object v2, p2

    move-object v3, p3

    move-object v4, p4

    move v5, p5

    move-wide/from16 v6, p6

    .line 131
    invoke-static/range {v0 .. v7}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->generateFilePath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)Ljava/lang/String;

    move-result-object v9

    .line 139
    .end local v0    # "basePath":Ljava/lang/String;
    .end local v8    # "baseDir":Ljava/io/File;
    :cond_83
    invoke-static {v9}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->getFilesystemRoot(Ljava/lang/String;)Ljava/io/File;

    move-result-object v1

    invoke-static {v1}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->getAvailableBytes(Ljava/io/File;)J

    move-result-wide v2

    cmp-long v1, v2, p6

    if-gez v1, :cond_c6

    .line 140
    new-instance v1, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v2, 0x1f2

    const-string v3, "insufficient space on external storage"

    invoke-direct {v1, v2, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v1

    .line 133
    :cond_99
    new-instance v1, Ljava/io/File;

    invoke-direct {v1, v9}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_83

    .line 134
    const-string v1, "DownloadManager"

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "File already exists: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 135
    new-instance v1, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;

    const/16 v2, 0x1e8

    const-string v3, "requested destination file already exists"

    invoke-direct {v1, v2, v3}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;-><init>(ILjava/lang/String;)V

    throw v1

    .line 145
    :cond_c6
    return-object v9
.end method

.method public static isExternalMediaMounted()Z
    .registers 2

    .prologue
    .line 284
    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v0

    const-string v1, "mounted"

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-nez v0, :cond_15

    .line 287
    const-string v0, "DownloadManager"

    const-string v1, "no external storage"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 288
    const/4 v0, 0x0

    .line 290
    :goto_14
    return v0

    :cond_15
    const/4 v0, 0x1

    goto :goto_14
.end method

.method public static isFilenameValid(Ljava/lang/String;)Z
    .registers 3
    .param p0, "filename"    # Ljava/lang/String;

    .prologue
    .line 525
    const-string v0, "/+"

    const-string v1, "/"

    invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replaceFirst(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object p0

    .line 527
    invoke-static {}, Landroid/os/Environment;->getDownloadCacheDirectory()Ljava/io/File;

    move-result-object v0

    .line 528
    invoke-virtual {v0}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v0

    .line 527
    invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v0

    if-nez v0, :cond_24

    .line 530
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v0

    invoke-virtual {v0}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v0

    .line 529
    invoke-virtual {p0, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v0

    if-eqz v0, :cond_26

    :cond_24
    const/4 v0, 0x1

    :goto_25
    return v0

    :cond_26
    const/4 v0, 0x0

    goto :goto_25
.end method

.method public static isNetworkAvailable(Lcom/zuimeia/sdk/download/providers/downloads/SystemFacade;)Z
    .registers 2
    .param p0, "system"    # Lcom/zuimeia/sdk/download/providers/downloads/SystemFacade;

    .prologue
    .line 518
    invoke-interface {p0}, Lcom/zuimeia/sdk/download/providers/downloads/SystemFacade;->getActiveNetworkType()Ljava/lang/Integer;

    move-result-object v0

    if-eqz v0, :cond_8

    const/4 v0, 0x1

    :goto_7
    return v0

    :cond_8
    const/4 v0, 0x0

    goto :goto_7
.end method

.method public static isSDCardAvailable(Landroid/content/Context;J)Z
    .registers 8
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "contentLength"    # J

    .prologue
    .line 306
    const/4 v0, 0x0

    .line 307
    .local v0, "canwrite":Z
    invoke-static {}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->isExternalMediaMounted()Z

    move-result v2

    if-eqz v2, :cond_14

    .line 308
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    .line 309
    .local v1, "root":Ljava/io/File;
    invoke-static {v1}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->getAvailableBytes(Ljava/io/File;)J

    move-result-wide v2

    cmp-long v2, v2, p1

    if-gez v2, :cond_15

    .line 310
    const/4 v0, 0x0

    .line 315
    .end local v1    # "root":Ljava/io/File;
    :cond_14
    :goto_14
    return v0

    .line 312
    .restart local v1    # "root":Ljava/io/File;
    :cond_15
    const/4 v0, 0x1

    goto :goto_14
.end method

.method private static locateDestinationDirectory(Landroid/content/Context;Ljava/lang/String;IJ)Ljava/io/File;
    .registers 6
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "mimeType"    # Ljava/lang/String;
    .param p2, "destination"    # I
    .param p3, "contentLength"    # J
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/zuimeia/sdk/download/providers/downloads/Helpers$GenerateSaveFileError;
        }
    .end annotation

    .prologue
    .line 250
    invoke-static {p3, p4}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->getExternalDestination(J)Ljava/io/File;

    move-result-object v0

    return-object v0
.end method

.method private static parseContentDisposition(Ljava/lang/String;)Ljava/lang/String;
    .registers 3
    .param p0, "contentDisposition"    # Ljava/lang/String;

    .prologue
    .line 64
    :try_start_0
    sget-object v1, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->CONTENT_DISPOSITION_PATTERN:Ljava/util/regex/Pattern;

    invoke-virtual {v1, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v0

    .line 65
    .local v0, "m":Ljava/util/regex/Matcher;
    invoke-virtual {v0}, Ljava/util/regex/Matcher;->find()Z

    move-result v1

    if-eqz v1, :cond_13

    .line 66
    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;
    :try_end_10
    .catch Ljava/lang/IllegalStateException; {:try_start_0 .. :try_end_10} :catch_12

    move-result-object v1

    .line 72
    .end local v0    # "m":Ljava/util/regex/Matcher;
    :goto_11
    return-object v1

    .line 68
    :catch_12
    move-exception v1

    .line 72
    :cond_13
    const/4 v1, 0x0

    goto :goto_11
.end method

.method private static parseExpression(Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;)V
    .registers 3
    .param p0, "lexer"    # Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;

    .prologue
    .line 565
    :goto_0
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x1

    if-ne v0, v1, :cond_27

    .line 566
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    .line 567
    invoke-static {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->parseExpression(Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;)V

    .line 568
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x2

    if-eq v0, v1, :cond_1c

    .line 569
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, unmatched parenthese"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 572
    :cond_1c
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    .line 577
    :goto_1f
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x3

    if-eq v0, v1, :cond_2b

    .line 582
    return-void

    .line 575
    :cond_27
    invoke-static {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->parseStatement(Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;)V

    goto :goto_1f

    .line 580
    :cond_2b
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    goto :goto_0
.end method

.method private static parseStatement(Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;)V
    .registers 3
    .param p0, "lexer"    # Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;

    .prologue
    .line 588
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x4

    if-eq v0, v1, :cond_f

    .line 589
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, expected column name"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 592
    :cond_f
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    .line 595
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x5

    if-ne v0, v1, :cond_2f

    .line 596
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    .line 597
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x6

    if-eq v0, v1, :cond_2b

    .line 598
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, expected quoted string"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 601
    :cond_2b
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    .line 613
    :goto_2e
    return-void

    .line 606
    :cond_2f
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/4 v1, 0x7

    if-ne v0, v1, :cond_4d

    .line 607
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    .line 608
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v0

    const/16 v1, 0x8

    if-eq v0, v1, :cond_49

    .line 609
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error, expected NULL"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 612
    :cond_49
    invoke-virtual {p0}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->advance()V

    goto :goto_2e

    .line 617
    :cond_4d
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "syntax error after column name"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method public static validateSelection(Ljava/lang/String;Ljava/util/Set;)V
    .registers 7
    .param p0, "selection"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Ljava/util/Set",
            "<",
            "Ljava/lang/String;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 539
    .local p1, "allowedColumns":Ljava/util/Set;, "Ljava/util/Set<Ljava/lang/String;>;"
    if-eqz p0, :cond_8

    :try_start_2
    invoke-virtual {p0}, Ljava/lang/String;->length()I

    move-result v2

    if-nez v2, :cond_9

    .line 557
    :cond_8
    return-void

    .line 542
    :cond_9
    new-instance v1, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;

    invoke-direct {v1, p0, p1}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;-><init>(Ljava/lang/String;Ljava/util/Set;)V

    .line 543
    .local v1, "lexer":Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;
    invoke-static {v1}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers;->parseExpression(Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;)V

    .line 544
    invoke-virtual {v1}, Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;->currentToken()I

    move-result v2

    const/16 v3, 0x9

    if-eq v2, v3, :cond_8

    .line 545
    new-instance v2, Ljava/lang/IllegalArgumentException;

    const-string v3, "syntax error"

    invoke-direct {v2, v3}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v2
    :try_end_21
    .catch Ljava/lang/RuntimeException; {:try_start_2 .. :try_end_21} :catch_21

    .line 547
    .end local v1    # "lexer":Lcom/zuimeia/sdk/download/providers/downloads/Helpers$Lexer;
    :catch_21
    move-exception v0

    .line 552
    .local v0, "ex":Ljava/lang/RuntimeException;
    const-string v2, "DownloadManager"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "invalid selection triggered "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 554
    throw v0
.end method
